#define _CRT_SECURE_NO_WARNINGS
#include<stdio.h>
#include <stdio.h>

int main() {
    int a, b, c;
    int br[13] = { 0,31,59,90,120,151,181,212,243,273,304,334,365 };
    int r[13] = { 0,31,60,91,121,152,182,213,244,274,305,335,366 };
    while (scanf("%d %d %d", &a, &b, &c) != EOF)
    {
        if ((a % 4 == 0) && (a % 100 != 0) || (a % 400 == 0))
        {
            for (int i = 1; i <= 12; i++)
            {
                if (i == b)
                {
                    printf("%d\n", r[i - 1] + c);
                }
            }
        }
        else
        {
            for (int i = 1; i <= 12; i++)
            {
                if (i == b)
                {
                    printf("%d\n", br[i - 1] + c);
                }
            }
        }
    }
    return 0;
}